home *** CD-ROM | disk | FTP | other *** search
/ Super PC 31 / Super PC 31 (Shareware).iso / spc / inter / winpm223 / forms / cryptxor / cryptxor.c next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  4.5 KB  |  108 lines

  1. //
  2. //  CryptXOR.C
  3. //  Runtime Loadable Encryptor Extension for Pegasus Mail for Windows.
  4. //  Copyright (c) 1995, David Harris, All Rights Reserved.
  5. //
  6. //  The author grants explicit permission for this source code to be
  7. //  used or modified as required, subject only to the conditions that
  8. //  the copyright notices above are preserved and that by using this
  9. //  code you agree that the code is provided without warranty of any
  10. //  kind, either explicit or implied, and you use it at your own
  11. //  risk.
  12. //
  13. //  This module implements a simple encryptor module to demonstrate
  14. //  the general format and layout such an extension should take.
  15. //
  16. //  *** WARNING!! The encryption method this module uses barely even
  17. //  *** warrants the title "encryptor"; it is a very simple algorithm
  18. //  *** that should be quite easy to break for anyone wishing to invest
  19. //  *** some time in standard cryptanalytical techniques.
  20. //  ***
  21. //  *** UNDER NO CIRCUMSTANCES SHOULD YOU REGARD THIS AS A WORKING
  22. //  *** ENCRYPTOR OFFERING ANY KIND OF SECURITY. IT IS INTENDED PURELY
  23. //  *** AS TUTORIAL CODE SHOWING IMPLEMENTATIONAL DETAIL.
  24. //
  25.  
  26. #define STRICT
  27. #include <windows.h>
  28. #include <bwcc.h>
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include "..\wpmforms.h"
  32.  
  33. HINSTANCE  hLibInstance;            // set in LibMain, used throughout the DLL
  34. HWND last_focus;
  35.  
  36. #pragma warn -par
  37.  
  38. //
  39. //  FORMINIT: Runtime Loadable Encryptors are simply a specialised form of
  40. //  WinPMail Extension. As such, they must follow the standard rules for
  41. //  such Extensions, including having an .FFF file to describe their char-
  42. //  acteristics to the Extensions Manager, and a routine called FORMINIT
  43. //  that is called when the module is loaded. For more information on
  44. //  Extensions, examine the files WPMFORMS.TXT and WPMFORMS.TXT supplied in
  45. //  the "FORMS" subdirectory of the WinPMail install directory. Note that
  46. //  an encryptor module can use the entire family of Extension Manager
  47. //  interface calls except those specific to READER Extensions.
  48. //
  49. //  In short, FORMINIT must take the following form:
  50. //
  51. //  WORD FAR PASCAL _export FORMINIT (WORD version, int variant, HWND hParent,
  52. //      char *data, HWND *hDialog, char *callback_name);
  53. //
  54. //  "version" is passed in with the version of the WinPMail forms
  55. //     manager which is running.
  56. //  "variant" indicates what type of form is required - the following
  57. //     values are currently defined:
  58. //       0: Create a form for composing a message
  59. //       1: Create a form for reading a message
  60. //  "hParent" contains the handle of the WinPMail MDI child window
  61. //     which is to contain the form. For encryptor modules this window
  62. //     will almost always be hidden.
  63. //  "data" contains any string defined as being required for the
  64. //     form in the menu interface.
  65. //  "hDialog" should be filled in with the window handle of the
  66. //     modeless dialog created within the MDI child window.
  67. //  "callback_name" (optional) should be filled in with the name of the
  68. //     function in the DLL of the exported function to which messages
  69. //     should be sent or NULL if there is none. If NULL, messages are
  70. //     sent to the dialog returned in "hDialog". You will use an
  71. //     indirect callback of this kind when your extension does not
  72. //     create a dialog within the enclosing parent window.
  73. //
  74. //  When forminit is called, the DLL should register any window
  75. //  classes it needs then create the dialog within the MDI parent
  76. //  window and size it to the correct size. On return WinPMail will
  77. //  resize the parent window to enclose the dialog correctly. The
  78. //  DLL should NOT make the dialog visible - WinPMail will do that
  79. //  as required.
  80.  
  81.  
  82. WORD FAR PASCAL _export FORMINIT (WORD version, int variant, HWND hParent,
  83.    char *data, HWND *hDialog, FORM_CALLBACK *callback)
  84.    {
  85.    //  First, check to see if the version of the form manager is
  86.    //  one we can work with. This check is pretty arbitrary - you
  87.    //  should probably assume that you may not work with any version
  88.    //  where the major version number is higher than the original
  89.    //  version you targeted.
  90.  
  91.    if ((version & 0xFF00) > 0x100) return 0;
  92.  
  93.    *hDialog = NULL;
  94.    return 1;
  95.    }
  96.  
  97.  
  98. BOOL FAR PASCAL LibMain (HINSTANCE hInst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  99.    {
  100.    //  This particular encryptor has no user interface as such
  101.    //  so we don't have to register any window classes or anything.
  102.  
  103.    if (! hLibInstance) hLibInstance = hInst;
  104.  
  105.    return (TRUE);             // Initialization went OK
  106.    }
  107.  
  108.